/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: kano
 * Date: 2025-02-01
 * Time: 23:13
 */
public class Test {
    public static void main(String[] args) {
        System.out.println("hello world");
        System.out.println(3.14);
        System.out.println(123);
        System.out.println('A');
        System.out.println(false);
        System.out.println(true);
        //
        System.out.println(Integer.MAX_VALUE);
        System.out.println(Integer.MIN_VALUE);
        //Java变量未初始化会报错
       // int c;
       //   System.out.println(c);//
        //长整形
        long a = 10L;
        long b = 10l;
        System.out.println("a: "+a);
        System.out.println("b: "+b);
        System.out.println(Long.MAX_VALUE);
        System.out.println(Long.MIN_VALUE);

        //short c = 12391093012; 溢出会直接报错
        System.out.println(Short.MAX_VALUE);
        System.out.println(Short.MIN_VALUE);
        //字节类型
        System.out.println(Byte.MAX_VALUE);
        System.out.println(Byte.MIN_VALUE);
        //double
        int ret1 = 1;
        int ret2 = 2;
        System.out.println(ret1/ret2);

        double ret3 = 1.0;
        double ret4 = 2.0;
        System.out.println(ret3/ret4);
        System.out.println(ret3/ret2);
        System.out.println(ret1/ret4);
        double num = 1.1;
        System.out.println(num*num);
        num = 1.2;
        System.out.println(num*num);
        System.out.println(Double.MAX_VALUE);
        System.out.println(Double.MIN_VALUE); //输出的是最小的非负数 double 类型能表示的最接近零的正数值
        System.out.println("负数: "+-Double.MAX_VALUE);
        System.out.println("负数: "+-Double.MIN_VALUE);

        // 1.1 和 1.2 在计算机中的二进制表示方式不同，1.1 更难准确表示，所以计算时更容易产生误差，
        // 而 1.2 相对容易在二进制中表示得比较精确。
        System.out.println(Float.MAX_VALUE);
        System.out.println(Float.MIN_VALUE);
        char c = 321; ///本质是整数->输出A
        char d = '哈';
        System.out.println(c);
        System.out.println((int)d);
        //布尔类型
        //boolean e = 1; 只能赋值true || false
        boolean e = true;
        boolean f = false;
        System.out.println(e+" "+f);
        //System.out.println(Boolean.); ，没有明确去规定大小
        //System.out.println(e+1); 布尔类型不能做运算
        //类型转换
        long t1 = 1000;
        short t2 = 20;
        //short t3 = t1; Java不允许范围大的赋值给范围小的 --- C语言可以但是会溢出发生截断
        short t3 = (short)t1;
        long t4 = t2; //范围小的赋值给范围大的会发生隐式类型转换

        double d1 = 90.2;
        float d2 = 21;
        d1 = d2;
        //d2 = d1; 也是不允许的

        byte b1 = 127;
        byte b2 = (byte)227; //将一个字面值常量进行赋值的时候, Java 会自动针对数字范围进行检查
        //boolean temp =  (boolean) 21; 不相干的不能类型转换
        //类型提升
        long del1 = 20;
        int del2 = 10;
        //int reasult = del1 + del2; del2整形提升成long 应该用long接收
        long reasult = del1 + del2;
        //小于4个字节的运算会提升为int
        short del3 = 20;
        byte del4 = 10;
        // short del5 = del4 + del3; 两个类型都需要转化为int
        int del5 = del3 + del4;

        //字符串与字符串拼接
        String str1 = "hello ";
        String str2 = "World";
        System.out.println(str1+str2);
        //字符串与其他类型的转换
        //(1) 其他类型转化为string
        //方法1：
        double dd = 12.2;
        System.out.println(dd+" sa"); //dd向上提升为字符串
        //方法2：使用valueof
        System.out.println(String.valueOf(dd));
        //(2) string转化为其他类型
        String s = "100";
        System.out.println("转化前只是字符串的拼接："+s+1);
        int ret = Integer.parseInt(s);
        double r = Double.parseDouble(s);
        System.out.println(r);//100.0
        System.out.println("转化后：ret+1 "+(ret+1)); //加括号先计算再拼接整数转为字符串
        System.out.println("转化后：ret+1 "+ret+1); //不加括号则是依次拼接

        System.out.println(5%2);
        System.out.println(5 == 2); //C语言输出的是0 这里输出的是boolean
    }
}
